Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

d3-force

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-force

Force-directed graph layout using velocity Verlet integration.

  • 1.2.1
  • one
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.6M
increased by7.29%
Maintainers
1
Weekly downloads
 
Created

What is d3-force?

The d3-force npm package is a module in the D3 (Data-Driven Documents) suite that provides a force-directed graph layout algorithm. It is used to simulate physical forces on particles and links in network graphs, enabling the creation of dynamic visualizations where nodes and links adjust their positions according to specified forces.

What are d3-force's main functionalities?

Force Simulation

This feature allows the creation of a force simulation for nodes and links. Nodes act like charged particles repelling each other while links act like springs connecting nodes. This code initializes a simulation with forces that affect node positioning and link connections.

const d3 = require('d3-force');
const simulation = d3.forceSimulation(nodes)
  .force('link', d3.forceLink(links).id(d => d.id))
  .force('charge', d3.forceManyBody())
  .force('center', d3.forceCenter(width / 2, height / 2));

Collision Detection

Collision detection prevents nodes from overlapping in the visualization. The 'forceCollide' function is used to keep nodes apart by specifying a radius for each node that determines its collision boundary.

const d3 = require('d3-force');
const simulation = d3.forceSimulation(nodes)
  .force('collision', d3.forceCollide().radius(d => d.radius));

Positioning Forces

This feature allows the application of forces that push nodes towards a specific position on the x and y axes. The strength of the force can be adjusted to control how aggressively nodes move towards the target position.

const d3 = require('d3-force');
const simulation = d3.forceSimulation(nodes)
  .force('x', d3.forceX(width / 2).strength(0.05))
  .force('y', d3.forceY(height / 2).strength(0.05));

Other packages similar to d3-force

Keywords

FAQs

Package last updated on 14 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc